package com.xc.mail.controller;



import org.apache.logging.log4j.LogManager;
import org.slf4j.Logger;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.context.request.WebRequest;
import static org.springframework.http.HttpStatus.NOT_EXTENDED;

/**
 * 传参错误拦截
 * 在controller里面内容执行之前，校验一些参数不匹配啊，Get post方法不对啊之类的
 */
@ControllerAdvice
public class GlobalExceptionHandler extends ReflectiveOperationException {



    protected ResponseEntity<Object> handleExceptionInternal(Exception ex, Object body, HttpHeaders headers, HttpStatus status, WebRequest request) {
        System.out.println("错误");

        return new ResponseEntity<Object>("出错了", NOT_EXTENDED);

    }
}
